import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../../../../lib_basemodel/chat_room/kh_chat_room_info_model.dart';
import '../../../../lib_baseview/widget/dialogs.dart';
import '../../interface/chat_room_leaf_interface.dart';
import '../../interface/room_page.dart';

class ChatRoomTapBarModel extends ChatRoomChangeNotifier {
  KHChatRoomInfoModel? get info =>
      roomModel.roomEnterModel?.chatRoomModel?.roomInfo;
  int? micCount;

  ChatRoomTapBarModel();

  clickBack(BuildContext context) {
    RoomPage.pop();
  }

  clickShare(BuildContext context) {
    showToast('分享');
  }

  openHotUserList(BuildContext context) {
    // if (channel != null) {
    //   RoomRankPage.bottomShow(channel!.channelId,
    //       displayType: RoomRankTypeEnum.cash);
    // }
  }

  openUserList(BuildContext context) {
    // if (channel != null) {
    //   RoomRankPage.bottomShow(channel!.channelId,
    //       displayType: RoomRankTypeEnum.online);
    // }
  }

  _openModalBottomSheet(BuildContext context, WidgetBuilder builder) {
    showModalBottomSheet(
      shape: const RoundedRectangleBorder(
        borderRadius: BorderRadius.only(
          topLeft: Radius.circular(24),
          topRight: Radius.circular(24),
        ),
      ),
      context: context,
      builder: builder,
    );
  }

  /// 收藏
  collect() async {
    // if (roomModel.channel == null) {
    //   return;
    // }
    // if (channel?.inMyCollection ?? false == true) {
    //   var result = await RtcApi.instance
    //       .cancelCollectChannel(roomModel.channel!.channelId);
    //   if (result.errorCode == 0) {
    //     showToast(T.current!.cancel_collect_suc);
    //     channel?.inMyCollection = false;
    //     roomModel.sendMessage(RoomConstant.MESSAGE_ID_CHANNEL_UPDATE);
    //     notifyListeners();
    //   } else {
    //     showToast(result.errorMsg ?? T.current!.cancel_collect_fail);
    //   }
    // } else {
    //   var result =
    //       await RtcApi.instance.collectChannel(roomModel.channel!.channelId);
    //   if (result.errorCode == 0) {
    //     showToast(T.current!.collect_suc);
    //     channel?.inMyCollection = true;
    //     roomModel.sendMessage(RoomConstant.MESSAGE_ID_CHANNEL_UPDATE);
    //     notifyListeners();
    //   } else {
    //     showToast(result.errorMsg ?? T.current!.collect_fail);
    //   }
    // }
  }
}
